package com.cw.reduce.filter;

import java.util.Vector;

public class BinFilter implements IFilter {
	int type;

	public BinFilter(int type) {
		this.type = type;
	}

	/**
	 * startFilter
	 * 
	 * @param condition
	 *            Vector
	 * @param target
	 *            Vector
	 * @return Vector
	 * @todo Implement this cp.gui.reduce.filter.IFilter method
	 */
	public Vector<Integer> startFilter(Vector condition, Vector<Integer> target) {
		Vector<Integer> result = new Vector<Integer>();
		int condint = 0;
		for (int i = 0; i < condition.size(); i++) {
			condint += 1 << (Integer) condition.elementAt(i);
		}
		for (int i = 0; i < target.size(); i++) {
			int value0 = target.elementAt(i);
			int value = value0;
			if (type == 0) {
				value = (1 << 10) - 1 - value;
			}
			if ((value & condint) == condint) {
				result.add(value0);
			}
		}
		return result;
	}
}
